/**
 * 暂且有问题，持久化
 */

import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage' // 持久化存储
import { rootReducer } from './store'
import { configureStore } from '@reduxjs/toolkit'

// 持久化配置
const persistConfig = {
	key: 'root', // 根节点
	storage, // 存储引擎
	whitelist: ['language'] // 只持久化 language reducer
}
// @ts-ignore
const persistedReducer = persistReducer(persistConfig, rootReducer)
const store = configureStore({
	reducer: persistedReducer, // 开启持久化
	middleware: (getDefaultMiddleware) => getDefaultMiddleware()
	// devTools: true, // 扩展工具是否打开
})
const persistor = persistStore(store) // 创建持久化存储
export { store, persistor }
